<template>
  <div>
    <van-goods-action>
      <van-goods-action-icon
        :icon="isCollected ? 'star' : 'star-o'"
        :text="isCollected ? '已收藏' : '未收藏'"
        :color="isCollected ? 'red' : 'black'"
        @click="onClickIcon"
      />
      <van-goods-action-icon icon="cart-o" text="购物车" :badge="goodsCount" />
      <van-goods-action-button
        type="danger"
        text="立即购买"
        @click="onClickButton"
      />
      <van-goods-action-button
        type="warning"
        text="加入购物车"
        @click="goToCart"
      />
    </van-goods-action>
  </div>
</template>

<script>
import { Toast } from "vant";

export default {
  data() {
    return {
      isCollected: false,
    };
  },
  methods: {
    onClickIcon() {
      this.isCollected = !this.isCollected;
    },
    goToCart() {
      this.$emit("goToCart");
    },
    onClickButton() {
      Toast("暂未开放立即购买功能");
    },
  },
  props: ["goodsCount"],
};
</script>

<style>
.van-goods-action {
  z-index: 99999;
}
</style>